package com.kc.gb.device.plugins.ptl.events;

import com.kc.gb.device.plugins.ptl.events.support.PtlPublishEvent;
import com.kc.gb.device.plugins.ptl.service.PtlMQService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class PtlEventListener {

    @Resource
    PtlMQService ptlMQService;

    @Async
    @EventListener(value = PtlPublishEvent.class)
    public void listenPtlPublishEvent(PtlPublishEvent command) throws Exception {
        // 发送 MQ 消息
        log.info("PtlPublishEvent:{}", command);
        ptlMQService.sendFeedBackMessage(command);
    }
}
